#pragma once

#include "vector3.h"

namespace krryn{
namespace view{
	typedef unsigned int pixel_t;
    typedef char color_t;

	class canvas{
	public:
		canvas(int a_Width, int a_Height);

		pixel_t *get_buffer() const;
		int get_width() const;
		int get_height() const;
		int get_pitch() const;
		void paint(int x, int y, pixel_t a_Color);
		math::color3 color_at(int x, int y);
		void lock();
		void unlock();
        void copy_to(canvas *a_Other);
		void flip();
        pixel_t mix_color(color_t r, color_t g, color_t b) const;
		pixel_t mix_color(const math::color3 &a_Color) const;
        void circle(int a_X, int a_Y, int a_Radius, pixel_t a_Color);
        
    private:
        pixel_t get_pixel(int x, int y);
        color_t clamp(const float a_Value) const;
        canvas(int a_Width, int a_Height, bool l_IsFrontBuffer);
        
   		pixel_t *m_Pixels;
		int m_Width;
		int m_Height;
		int m_Pitch;
		bool m_Locked;
	};
}
}
